﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Koonsoft.CustomerService.DAL;
using Koonsoft.CustomerService.Entity;

namespace Koonsoft.CustomerService.BLL
{
    public class WFBLL
    {
        private WFDAL _dal = null;

        protected WFDAL DAL
        {
            get
            {
                if (_dal == null)
                {
                    _dal = new WFDAL();
                }

                return _dal;
            }
        }

        public WF GetFirstWF(out string msg)
        {
            return DAL.GetFirstWF(out msg);
        }

        public WF GetWfById(int id)
        {
            WF wf = DAL.GetWfById(id);
            if (wf == null)
            {
                return new WF();
            }
            else
            {
                return wf;
            }
        }

        public WF GetNextWf(int id)
        {
            WF wf = GetNextWfById(id);
            if (wf == null)
            {
                return new WF();
            }
            else
            {
                return wf;
            }
        }

        private WF GetNextWfById(int id)
        {
            return DAL.GetNextWf(id);
        }

        private WF GetWfByStateName(string stateName)
        {
            return DAL.GetWfByStateName(stateName);
        }

        public int GetWfByState(string stateName)
        {
            WF wf = DAL.GetWfByStateName(stateName);
            if (wf == null)
            {
                return 999;
            }
            else
            {
                return wf.WFID;
            }
        }
    }
}
